package dto;

import java.util.Date;

/**
 * @author Jonathan Maret
 * Class used to manage contacts
 * Two contacts are equals if everything corespond but there id 
 * To string return "lastname firstname - visa"
 *
 */
public class DTOContact {
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((address == null) ? 0 : address.hashCode());
		result = prime * result
				+ ((birthdate == null) ? 0 : birthdate.hashCode());
		result = prime * result + compagny;
		result = prime * result + ((email == null) ? 0 : email.hashCode());
		result = prime * result
				+ ((firstname == null) ? 0 : firstname.hashCode());
		result = prime * result + id;
		result = prime * result
				+ ((lastname == null) ? 0 : lastname.hashCode());
		result = prime * result
				+ ((locality == null) ? 0 : locality.hashCode());
		result = prime * result + npa;
		result = prime * result + ((phone == null) ? 0 : phone.hashCode());
		result = prime * result + typeOfContact;
		result = prime * result + ((visa == null) ? 0 : visa.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DTOContact other = (DTOContact) obj;
		
		if (birthdate == null) {
			if (other.birthdate != null)
				return false;
		} else if (!birthdate.equals(other.birthdate))
			return false;
		
		if (firstname == null) {
			if (other.firstname != null)
				return false;
		} else if (!firstname.equals(other.firstname))
			return false;
		if (lastname == null) {
			if (other.lastname != null)
				return false;
		} else if (!lastname.equals(other.lastname))
			return false;
		if (visa == null) {
			if (other.visa != null)
				return false;
		} else if (!visa.equals(other.visa))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return lastname + " " + firstname + " - " + visa;
	}
	private int id;
	private int compagny;
	private String lastname;
	private String firstname;
	private String visa;
	private Date birthdate;
	private int	typeOfContact;
	private String phone;
	private String email;
	private String address;
	private String locality;
	private int npa;
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getCompagny() {
		return compagny;
	}

	public void setCompagny(int compagny) {
		this.compagny = compagny;
	}

	public String getLastname() {
		return lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public String getFirstname() {
		return firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public String getVisa() {
		return visa;
	}

	public void setVisa(String visa) {
		this.visa = visa;
	}

	public Date getBirthdate() {
		return birthdate;
	}

	public void setBirthdate(Date birthdate) {
		this.birthdate = birthdate;
	}

	public int getTypeOfContact() {
		return typeOfContact;
	}

	public void setTypeOfContact(int typeOfContact) {
		this.typeOfContact = typeOfContact;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getLocality() {
		return locality;
	}

	public void setLocality(String locality) {
		this.locality = locality;
	}

	public int getNpa() {
		return npa;
	}

	public void setNpa(int npa) {
		this.npa = npa;
	}

	public DTOContact(int id, int compagny, String lastname, String firstname,
			String visa, Date birthdate, int typeOfContact, String phone,
			String email, String address, String locality, int npa) {
		super();
		this.id = id;
		this.compagny = compagny;
		this.lastname = lastname;
		this.firstname = firstname;
		this.visa = visa;
		this.birthdate = birthdate;
		this.typeOfContact = typeOfContact;
		this.phone = phone;
		this.email = email;
		this.address = address;
		this.locality = locality;
		this.npa = npa;
	}

	

}
